import {authLogin,authType} from "/api/user"
import store from "/store/index.js"
export const login=async ()=>{
	return new Promise((resolve,reject)=>{
		console.log('登录中')
		wx.login({
			success:async (res)=>{
				let auth_type = await authType({params:{code:res.code}})
				let loginRes = await authLogin({params:{key:auth_type.data.key}})
				store.commit('user/setToken',loginRes.data.token)
				store.dispatch('user/setUserInfo')
				resolve();
				// console.log(loginRes)
			}
		})
	})
}